<html>

<body>

<div align="center">

<script type="text/javascript" src="gears_init.js"></script>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAiX9tBRDFbSgpakElIrWwkxRPChpfF5Ia2CLmueUrh3dACB065BR3Jr-lSQxV512XsUirT_Iwdt2zLA"></script>
    <script type="text/javascript">




function initialize() {
	if (GBrowserIsCompatible()) {
	
		if (!window.google || !google.gears) { 
   
			var map = new GMap2(document.getElementById("map_canvas"));
		        map.setCenter(new GLatLng(24.442305101770724,54.45819854736328), 12);
		        map.addControl(new GSmallMapControl());
		        map.addControl(new GMapTypeControl());       
			<?php 
				$Codess = explode(" SPLIT ", $_POST[mydropdown1]);
		
				echo 'var encodedPoints = "' . $Codess[1] . '" ;';
				echo 'var encodedLevels = "' . $Codess[0] . '" ;';

				echo 'var startstopXY = new GLatLng('.$Codess[3].');';
				echo 'var endstopXY = new GLatLng('.$Codess[4].');';
		
				echo 'markerOptions = {title:"'.$Codess[5].'" };';
				echo 'markerOptions1 = {title:"'.$Codess[6].'" };';
			?>
		
	      
		        var encodedPolyline = new GPolyline.fromEncoded({
		        color: "#0000FF",
		        weight: 5,
			opacity: 0.9,
		        points: encodedPoints,
		        levels: encodedLevels,
		        zoomFactor: 32,
		        numLevels: 4
		        });
		        map.addOverlay(encodedPolyline);

			var startmarker = new GMarker(startstopXY, markerOptions);
			map.addOverlay(startmarker);

			var endmarker = new GMarker(endstopXY, markerOptions1);
			map.addOverlay(endmarker);
		} 
		else
		{
  		        var geo = google.gears.factory.create('beta.geolocation');
       	
			if (!geo.getPermission()) {
	 
				alert('No permission to show your current position!!!!');
			}
	 
			function updatePosition(position) {

			        var map = new GMap2(document.getElementById("map_canvas"));
			        map.setCenter(new GLatLng(24.442305101770724,54.45819854736328), 12);
			        map.addControl(new GSmallMapControl());
			        map.addControl(new GMapTypeControl());       
				<?php 
					$Codess = explode(" SPLIT ", $_POST[mydropdown1]);
		
					echo 'var encodedPoints = "' . $Codess[1] . '" ;';
					echo 'var encodedLevels = "' . $Codess[0] . '" ;';

					echo 'var startstopXY = new GLatLng('.$Codess[3].');';
					echo 'var endstopXY = new GLatLng('.$Codess[4].');';
		
					echo 'markerOptions = {title:"'.$Codess[5].'" };';
					echo 'markerOptions1 = {title:"'.$Codess[6].'" };';
				?>
		
      
			        var encodedPolyline = new GPolyline.fromEncoded({
			        color: "#0000FF",
			        weight: 5,
				opacity: 0.9,
			        points: encodedPoints,
			        levels: encodedLevels,
	  		        zoomFactor: 32,
			        numLevels: 4
			        });
			        map.addOverlay(encodedPolyline);

				var startmarker = new GMarker(startstopXY, markerOptions);
				map.addOverlay(startmarker);

				var MyposXY = new GLatLng(position.latitude , position.longitude);

				var endmarker = new GMarker(endstopXY, markerOptions1);
				map.addOverlay(endmarker);

				var blueIcon = new GIcon(G_DEFAULT_ICON);
			        blueIcon.image = "http://gmaps-samples.googlecode.com/svn/trunk/markers/pink/blank.png";


				markerOptions2 = {title:"You are here",  icon:blueIcon };

			        var myPos = new GMarker(MyposXY ,markerOptions2);
				map.addOverlay(myPos);

			}
		
		}

		function handleError(positionError) {
			  alert('Attempt to get location failed: ' + positionError.message);

		        var map = new GMap2(document.getElementById("map_canvas"));
		  
		        map.setCenter(new GLatLng(24.442305101770724,54.45819854736328), 12);
		        map.addControl(new GSmallMapControl());
        		map.addControl(new GMapTypeControl());
       
			<?php 
				$Codess = explode(" SPLIT ", $_POST[mydropdown1]);

				echo 'var encodedPoints = "' . $Codess[1] . '" ;';
				echo 'var encodedLevels = "' . $Codess[0] . '" ;';

				echo 'var startstopXY = new GLatLng('.$Codess[3].');';
				echo 'var endstopXY = new GLatLng('.$Codess[4].');';

				echo 'markerOptions = {title:"'.$Codess[5].'" };';

				echo 'markerOptions1 = {title:"'.$Codess[6].'" };';
			?>
		
      
        		var encodedPolyline = new GPolyline.fromEncoded({
          		color: "#0000FF",
          		weight: 5,
	  		opacity: 0.9,
          		points: encodedPoints,
          		levels: encodedLevels,
          		zoomFactor: 32,
          		numLevels: 4
       			 });
        		map.addOverlay(encodedPolyline);


			var startmarker = new GMarker(startstopXY, markerOptions);
			map.addOverlay(startmarker);

			var endmarker = new GMarker(endstopXY, markerOptions1);
			map.addOverlay(endmarker);


		}

		geo.getCurrentPosition(updatePosition, handleError);

      	}
	else
	{

     		var map = new GMap2(document.getElementById("map_canvas"));
        	map.setCenter(new GLatLng(24.442305101770724,54.45819854736328), 12);
	        map.addControl(new GSmallMapControl());
	        map.addControl(new GMapTypeControl());       
        
		<?php 
			$Codess = explode(" SPLIT ", $_POST[mydropdown1]);

			echo 'var encodedPoints = "' . $Codess[1] . '" ;';
			echo 'var encodedLevels = "' . $Codess[0] . '" ;';

			echo 'var startstopXY = new GLatLng('.$Codess[3].');';
			echo 'var endstopXY = new GLatLng('.$Codess[4].');';

			echo 'markerOptions = {title:"'.$Codess[5].'" };';

			echo 'markerOptions1 = {title:"'.$Codess[6].'" };';
		?>
		
      
	     	 var encodedPolyline = new GPolyline.fromEncoded({
        	 color: "#0000FF",
	         weight: 5,
		 opacity: 0.9,
	         points: encodedPoints,
	         levels: encodedLevels,
	         zoomFactor: 32,
	         numLevels: 4
	        });
	        map.addOverlay(encodedPolyline);

		var startmarker = new GMarker(startstopXY, markerOptions);
		map.addOverlay(startmarker);

		var endmarker = new GMarker(endstopXY, markerOptions1);
		map.addOverlay(endmarker);

	

	}
    }
</script>

<?php
include ("connect.php");
$dbname = 'Transportation';
mysql_select_db($dbname);
$page_title = "Abu Dhabi Transportation Website - Maps";

$leftMenu = array
	(
		 "Home" => "index.php",
		"Routes" => "routes.php",
		"Schedule" => "Schedule.php",
		"Stops" => "Stops.php",
		"How To Go There" => "banner.php",
	);

$content = "<br/><br/>This is the Map for ";

$q = "select distinct RouteCode from busroutes where BusID ='$_POST[mydropdown1]'";
$result = mysql_query($q);
$shresult=mysql_fetch_array($result);

$Codess = explode(" SPLIT ", $_POST[mydropdown1]);

$content .= 'Route: ';

$content .= $Codess[2];
$content .= '<br/><br/><br/>';


$content .= ' <body onload="initialize()" onunload="GUnload()" style="font-family: Arial;border: 0 none;">
    <div id="map_canvas" style="width: 900px; height: 500px"></div>';

	    

$content .= '<br/><br/>';

mysql_close($connect);
$content .= '<br/><br/><br/><br/>';


include("default_layout.php");
?>





</div>
</form>
</body>
</html>